const { HabitUrl } = require("../../../config/config")

// pages/habit/habitLibrary/habitLibrary.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    habits:[]
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let _this = this 
    wx.request({
      url: HabitUrl+'/list_default',
      method: 'GET', 
      success: function(res){
        _this.setData({
          habits : res.data.result
        })
      }
    })

  },
  createMyHabit:function(){
    wx.navigateTo({
      url: '/pages/habit/addHabit/addHabit',
    })
  },
  createNewHabit:function(e){
    let hid = e.currentTarget.dataset.hid
    wx.navigateTo({
      url: '/pages/habit/addHabit/addHabit?selectHabitId='+hid,
    })
  },
})